﻿namespace KrasDD.Utils
{
    public class JSON
    {
        static JsonSerializerSettings settings = new JsonSerializerSettings()
        {
            ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
            StringEscapeHandling = StringEscapeHandling.Default,
            PreserveReferencesHandling = PreserveReferencesHandling.Objects
        };


        public static string Serialize(object obj)
        {

            return JsonConvert.SerializeObject(obj, settings);
        }

        public static T Deserialize<T>(string json)
        {

            return JsonConvert.DeserializeObject<T>(json, settings);
        }

        public static object Deserialize(string json, Type type)
        {
            return JsonConvert.DeserializeObject(json, type, settings);
        }
    }
}
